#! /bin/bash

# ssh  -i id_rsa-pstam-keypair ubuntu@ec2-23-20-125-28.compute-1.amazonaws.com


# print "hello M2PGI students":
# ssh -i /home/vince/boulot/fac/2011-2012/ecom/3svn-ecom/ecom-coloc/branches/ecom/src/main/java/ecom/id_rsa-pstam-keypair ubuntu@ec2-23-20-125-28.compute-1.amazonaws.com 'source ~/.bashrc; sh hadoop-0.20.2/data/hello.sh' 

LINES=10
if [ $# -eq '1' ] ; then
	echo "un param : $1"
    LINES=$1
fi

# call to top_IPs : on peut lui passer un nombre de fichiers en parametre, par défaut = 10
ssh -i /home/vince/boulot/fac/2011-2012/ecom/3svn-ecom/ecom-coloc/branches/ecom/src/main/java/ecom/id_rsa-pstam-keypair ubuntu@ec2-23-20-125-28.compute-1.amazonaws.com "source ~/.bashrc; sh hadoop-0.20.2/data/call_top_IPs.sh $LINES" > result_top_IPs.txt

# et à distance :
# #! /bin/bash

# LINES=10
# if [ $# -eq 1 ] ; then
#         LINES=$1
# fi

# cd hadoop-0.20.2/data

# if [ -e out/my_top_IP/part* ] ; then
#         echo "Top-IPs est a jour."
#         head -n $LINES out/my_top_IP/part*

# else
#         echo "Top files n'est pas a jour : lancement de hadoop."
#         rake ips && head -n $LINES out/my_top_IP/part*
# fi